﻿using System.Data.Linq;
using System.Data.Linq.Mapping;

namespace DebIt.Persistence.Model
{
    [Table(Name = "LoanItems")]
    public class LoanItemPo
    {
        #region variables

        [Column(IsVersion = true)]
        private Binary _version;
        private EntityRef<LoanPo> _loan;

        #endregion


        #region properties

        [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false,
            AutoSync = AutoSync.OnInsert)]
        public int LoanItemId { get;  set; }

        [Column(CanBeNull = false)]
        public int LoanId { get; set; }

        [Association(Storage = "_loan", ThisKey = "LoanId", IsForeignKey = true)]
        public LoanPo Loan
        {
            get { return _loan.Entity; }
            set
            {
                _loan.Entity = value;
            }
        }

        [Column(CanBeNull = true)]
        public string Description { get; set; }

        [Column(CanBeNull = false)]
        public decimal Value { get; set; }

        #endregion

    }
}
